#-*- coding:utf8 -*-
import os.path
from django.conf.urls.defaults import *
from django.conf.urls import patterns, url, include
from django.views.generic.simple import direct_to_template



from rest_framework.urlpatterns import format_suffix_patterns


from django.contrib import admin
admin.autodiscover()

#from wms.record.models import Project, Record, Cost, Account
import record
import master.views
import worksheet.views
import util.views
#import admin.views

from record.views import *

import master.models
#admin.site.register(Project)
#admin.site.register(Record)
#admin.site.register(Cost)
#admin.site.register(Account)
#admin.site.register(master.models.MasterCode)
#admin.site.register(master.models.UserProfiles)
admin.site.register(master.models.Groups)
#admin.site.register(master.models.Companies)
#admin.site.register(master.models.Depts)


resources = os.path.join(os.path.dirname(__file__), 'resources')

#dummy = record.FooUrl()

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()



from rest.views import UserList, UserDetail, GroupList, GroupDetail, DeptList

urlpatterns = patterns('rest.views',
    url(r'^root/$', 'api_root'),
    
    url(r'^users/$', UserList.as_view(), name='user-list'),
    #url(r'^users/$', UserList.get, name='user-list'),
    url(r'^users/(?P<pk>\d+)/$', UserDetail.as_view(), name='user-detail'),
    url(r'^groups/$', GroupList.as_view(), name='group-list'),
    url(r'^groups/(?P<pk>\d+)/$', GroupDetail.as_view(), name='group-detail'),
    
    
    url(r'^foo/$', DeptList.as_view(), name="foo"),
    
    
    
    #url(r'^users/$', UserList.as_view(), name='user-list'),
    
)                        
                        
# Format suffixes
urlpatterns = format_suffix_patterns(urlpatterns, allowed=['xml','json', 'api'])


urlpatterns += patterns('',
    # Example:
    # (r'^wms/', include('wms.foo.urls')),

    # Uncomment the admin/doc line below and add 'django.contrib.admindocs'
    # to INSTALLED_APPS to enable admin documentation:
    # (r'^admin/doc/', include('django.contrib.admindocs.urls')),

    (r'^i18n/', include('django.conf.urls.i18n')),
    # Uncomment the next line to enable the admin:
    (r'^resources/(?P<path>.*)$', 'django.views.static.serve', { 'document_root' : resources }),

    (r'^admin/', include(admin.site.urls)),
    #(r'^$', record.views.main_page),


    (r'^user/(\w+)/$', master.views.user_info),
    (r'^user/picture/(?P<file_code>\w*)/$', master.views.picture),



    (r'^$', worksheet.views.hello_page), # hello page
    (r'^login/$',  master.views.login), #로그인

    #(r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'registration/login.html'}),
    (r'^logout/$', record.views.user_logout),


    (r'^register/$', record.views.register_page),
    (r'^register/success/$', direct_to_template, {'template':'registration/register_success.html'}),


    (r'^record/sheet/$', record.views.sheet_page),
    (r'^record/sheet/(?P<duration>\w*)/$', record.views.sheet_page),


    (r'^account/create/$', account_create_page),
    #(r'^account/list/$', dummy.account_list_page),
    #(r'^account/edit/(?P<account_code>\w*)/$', dummy.account_edit_page),

    (r'^record/test/$', record.views.testpage),

    url(r'^project/create$', master.views.project_create, name='project_create'),
    url(r'^project/info/(?P<project_code>\w*)/$', master.views.project_info),
    (r'^project/list$', master.views.project_list),





    (r'^grid/$', direct_to_template, {'template':'grid.html'}),



    (r'^code/list/$', master.views.code_list), #주코드 코드목록
    #(r'^code/list/(?P<super_code>\w*)/$', master.views.code_list), #주코드 코드목록
    url(r'^code/list/(?P<data>.*)/$', master.views.code_list), #주코드 코드목록


    #(r'^code/info/(?P<code>\w+)/$', master.views.code_info), #코드상세
    url(r'^code/info/(?P<code>[^/]+)/$',master.views.code_info), #코드상세
    url(r'^code/create$',master.views.code_create), #코드 등록
    url(r'^code/edit/(?P<code>[^/]+)/$',master.views.code_edit), #코드 수정
    url(r'^code/select/$',master.views.code_select),

    #url(r'^browser/(?P.+)/$', browser_proxy, name='browser_proxy'),

    url(r'^dept/tree/$', master.views.dept_tree), #부서트리
    url(r'^dept/ajax/$', master.views.dept_ajax), #부서트리


    url(r'^customer/list/$', master.views.customer_list), #고객사정보
    url(r'^customer/info/$', master.views.dept_ajax), #고객사정보
    url(r'^customer/create/$', master.views.dept_ajax), #고객사정보
    url(r'^customer/edit/$', master.views.dept_ajax), #고객사정보
    url(r'^customer/select/$', master.views.dept_ajax), #고객사정보



    


    
    

)

from util.views import Controller
urlpatterns += patterns('',
    url(r'^util/getcode/$', Controller.as_view()),
    url(r'^util/getcode/time/$', Controller.as_view(), {'type':'time'}),
    url(r'^util/getcode/hash/$', Controller.as_view(), {'type':'hash'}),
    url(r'^util/getcode/date/$', Controller.as_view(), {'type':'date'}),
)
    


